/*
 * This program is free software: you can redistribute it and/or modify it under the terms of the 
 * GNU Affero General Public License as published by the Free Software Foundation, either version 3 
 * of the License, or (at your option) any later version.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3, 
 * the Appropriate Legal Notices must display the following words on all interactive user interfaces: 
 * "Copyright (C) 2005-2011 SplendidCRM Software, Inc. All rights reserved."
 */

var SplendidError =
{
	divError: null
	, bDebug: true
	, arrErrorLog: new Array()
	
	, SystemError: function(e, method)
	{
		var message = this.FormatError(e, method);
		this.arrErrorLog.push(message);
		if ( this.divError != null )
			this.divError.innerHTML = message;
	}
	, SystemMessage: function(message)
	{
		if ( message != null )
		{
			if ( message != '' )
				this.arrErrorLog.push(message);
			if ( this.divError != null )
				this.divError.innerHTML = message;
		}
	}
	, SystemLog: function(message)
	{
		if ( message != null && message != '' )
		{
			this.arrErrorLog.push(message);
		}
	}
	, SystemDebug: function(message)
	{
		if ( message != null )
		{
			if ( message != '' )
				this.arrErrorLog.push(message);
			if ( this.divError != null && bDebug )
				this.divError.innerHTML = message;
		}
	}
	, SystemAlert: function(e, method)
	{
		var message = this.FormatError(e, method);
		this.arrErrorLog.push(message);
		alert(message);
	}
	, FormatError: function(e, method)
	{
		return e.message + '<br>\n' + dumpObj(e, method);
	}
};


